![]() ![]() |
Q: I'm writing a
background-only application
which typically has very small memory requirements. However, in some
circumstances the application needs a lot of memory for a short
period of time. I would use temporary memory, but
Inside Macintosh:
Memory says that I can't leave that memory locked around calls to
A: No. DTS believes that it's better for your application to allocate and lock temporary memory than to allocate memory in the system heap. This opinion is based on a number of factors, described below. The original reference from Inside Macintosh: Memory (pp. 2-10) is:
However, the text should read:
If you leave a temporary memory handle locked while yielding time to other processes, you run the risk of fragmenting the Process Manager heap. If the Process Manager heap is fragmented, the user may not be able to launch an application, even though there is enough total memory to launch it. This is a very frustrating user experience, partly because there is no way for a user to work out which application is responsible for the block that's fragmenting the heap. However, if your memory requirements are indeed temporary, it is acceptable to allocate the memory, lock it, use it for a while, and then unlock or deallocate it. This is certainly better than any of the alternatives:
If you do lock a temporary memory handle, you should call
[Aug 24 1998] |
Developer Documentation | Technical Notes | Development Kits | Sample Code |